{
open Parser
exception EoF

let keyword = [("fun",FUN);("let",LET);("letrec",LETREC);("if",IF);("then",THEN);("else",ELSE);("in",IN);("print",PRINT);("hd",HD);("tl",TL);("not",NOT);("square",SQUARE);("cube",CUBE);("abs",ABS);("isnull",ISNULL)]

}
rule token = parse
  [' ' '\t']	{ token lexbuf }
  | ['\n' ]    	{ EOL }
  | ['0'-'9']+ 	{ INT (int_of_string (Lexing.lexeme lexbuf)) }
  | "true"      { BOOL (bool_of_string (Lexing.lexeme lexbuf)) }
  | "false"     { BOOL (bool_of_string (Lexing.lexeme lexbuf)) }
  | "->"        { TO }
  | '+'        	{ PLUS }
  | '*'        	{ TIMES }
  | '/'        	{ DIV }
  | '-'        	{ MINUS }
  | '%'        	{ MOD }
  | "=="       	{ EQQ }
  | "!="       	{ NEQ }
  | '='        	{ EQ }
  | '<'        	{ MINOR }
  | '>'        	{ MAJOR }
  | "<="       	{ MINOREQ }
  | ">="       	{ MAJOREQ }
  | "&&"       	{ AND }
  | "||"       	{ OR }
  | "::"       	{ CONS }
  | ';'        	{ SEMICOLON }
  | '('        	{ LPAREN }
  | ')'        	{ RPAREN }
  | '['        	{ LQUADRA}
  | ']'        	{ RQUADRA }
  | ['a'-'z']['A'-'Z' 'a'-'z' '0'-'9' '_']*   { try List.assoc (Lexing.lexeme lexbuf) (keyword) with Not_found -> (VAR (Lexing.lexeme lexbuf)) }
  | eof        	{ EOL }
  
  